package com.javaweb.admin.mapper;

import com.javaweb.admin.entity.GspUnQualified;
import com.javaweb.admin.entity.MaintainReport;
import com.javaweb.admin.entity.TransReport;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface KDLMapper {

    @Select("select * from v_kdl_maintain_report left join t_kdl_maintain_report_status on v_kdl_maintain_report.inspectionlot=t_kdl_maintain_report_status.inspectionlot where t_kdl_maintain_report_status.inspectionlot is null")
    List<MaintainReport> getMaintaiReportList();
    @Insert(" insert into t_kdl_maintain_report_status (inspectionlot) values (#{inspectionlot})")
    void updateMaintaiReportStatus(String inspectionlot);

    @Select("select top 200 * from v_gsp_shiprecords left join t_kdl_trans_report_status on v_gsp_shiprecords.pk_trans=t_kdl_trans_report_status.pk_trans where v_gsp_shiprecords.materialtype <> '第二类精神药品' and t_kdl_trans_report_status.pk_trans is null")
    List<TransReport> getTransReportList();

    @Insert("if not exists(select pk_trans from t_kdl_trans_report_status where pk_trans=#{pkTrans}) insert into t_kdl_trans_report_status (pk_trans,materialtype) values (#{pkTrans},#{materialtype})")
    void updateTransReportStatus(String pkTrans,String materialtype);

    @Select("select * from v_gsp_shiprecords left join t_kdl_trans_report_status on v_gsp_shiprecords.pk_trans=t_kdl_trans_report_status.pk_trans where v_gsp_shiprecords.materialtype like '%二类精神%' and t_kdl_trans_report_status.pk_trans is null")
    List<TransReport> getTransReportListSpecial();

    @Select("select * from v_gsp_unqualified left join t_gsp_unqualified_status on v_gsp_unqualified.pk_gsp=t_gsp_unqualified_status.pk_gsp where t_gsp_unqualified_status.pk_gsp is null  and isnull(expireddate,'')<>''")
    List<GspUnQualified> getGspUnQualifiedList();

    @Insert("if not exists(select pk_gsp from t_gsp_unqualified_status where pk_gsp=#{pk_gsp}) insert into t_gsp_unqualified_status (pk_gsp) values (#{pk_gsp})")
    void updateUnqualifiedStatus(String pk_gsp);

}
